/**
 * 顶部信息提示面板
 */

//--------------------------------------------------------------------------
//
//	初始化
//
//--------------------------------------------------------------------------
var infopad = null;

//页面载入初始化
$( "body" ).ready( function( e )
{
	infopad = new InfoPad();
	infopad.init();
} );

//--------------------------------------------------------------------------
//
//	智能提交表单系统类
//
//--------------------------------------------------------------------------

function InfoPad()
{
	this.html = "<div id='__INFO_PAD' onselectstart='return false' style='border-bottom:1px solid #666;background:#ffe;padding:10px 100px 10px 100px;font-size:16px;position:fixed;z-index:99999;'></div>";

	// 初始化
	this.init = function()
	{
		$( "body" ).append( this.html );
		$( "#__INFO_PAD" ).css( {
			"-moz-user-select": "none",
			"cursor": "default",
			"overflow": "hidden",
			"text-align": "center"
		} );
		$( "#__INFO_PAD" ).alpha( .98 );
		$( "#__INFO_PAD" ).hide();
	};

	// 显示单条信息
	this.show = function( msg, color, delay )
	{
		if( color == undefined )
			color = "#333333";

		$( "#__INFO_PAD" ).css( "color", color );
		$( "#__INFO_PAD" ).html( msg );
		$( "#__INFO_PAD" ).width( $( window ).width() - 200 );

		delay = typeof ( delay ) == "undefined" ? 2000 : delay * 1000;
		var dh = $( "#__INFO_PAD" ).outerHeight();

		// 双击强制立即隐藏
		$( "#__INFO_PAD" ).dblclick( function()
		{
			$( "#__INFO_PAD" ).finish();
			$( "#__INFO_PAD" ).hide();
			$( "#__INFO_PAD" ).unbind( "click" );
		} );

		$( "#__INFO_PAD" ).finish();
		$( "#__INFO_PAD" ).show();
		$( "#__INFO_PAD" ).move( 0, 0 );
		$( "#__INFO_PAD" ).delay( delay ).animate( {
			top: -dh
		}, 200, function()
		{
			$( "#__INFO_PAD" ).hide();
		} );
	};

	/**
	 * 提示错误信息
	 * 
	 * @param msg 提示内容
	 * @param delay 停留时间（单位：秒）
	 */
	this.err = function( msg, delay )
	{
		this.show( msg, "#dd0000", delay );
	};

	this.msg = function( msg, delay )
	{
		this.show( msg, "#77cc00", delay );
	};

	this.warn = function( msg, delay )
	{
		this.show( msg, "#cc9900", delay );
	};
}
